﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLThuVien
{
    class NXB
    {
        string manxb, tennxb;
        public NXB() { }
        public NXB(string manxb, string tennxb)
        {
            this.manxb = manxb;
            this.tennxb = tennxb;
        }

        public void set_manhaxuatban(string manxb)
        {
            this.manxb = manxb;
        }

        public void set_tennxb(string tennxb)
        {
            this.tennxb = tennxb;
        }

        public bool taomoi()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("insert into NXB values('" + manxb + "',N'" + tennxb + "')") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool update()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("update NXB set tennxb=N'" + tennxb + "' where manxb='" + manxb + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool xoa()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("delete from NXB where manxb='" + manxb + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
    }
}
